// 点击数字查看详细页面
function detailInfo(title, num, url) {
    if (null != url && url != '') {
        var roots = $('#menuTree').tree('getRoots');
        for (var i = 0; i < roots.length; i++) {
            var node = $('#menuTree').tree('getData', roots[i].target);
            var children = $('#menuTree').tree('getChildren', node.target);
            for (var j = 0; j < children.length; j++) {
                if (children[j].attributes.url == url) {
                    $("#menuTree").tree('expand', node.target);
//                    opentabs(children[j].text, children[j].attributes.url+'?type=1&spzt=ybc', children[j].attributes.type);
                    $('#menuTree').tree('select', children[j].target);
                }
            }
        }
    }
}

//在右边center区域打开菜单，新增tab
function opentabs(text, url, type) {
    if ($("#tabs").tabs('exists', text)) {
        $('#tabs').tabs('select', text);
        $('#tabs').tabs('getSelected').panel("refresh");
    } else if (type == 'bbtj') {
        $('#tabs').tabs('add', {
            title: text,
            cache: true,
            closable: true,
            content: '<iframe scrolling="no" frameborder="0" src="' + url + '" style="width:100%;height:100%;"></iframe>'
            //href: '../' + url
        });
    } else {
        $('#tabs').tabs('add', {
            title: text,
            cache: true,
            closable: true,
//                content: '<iframe scrolling="no" frameborder="0" src="../'+url+'" style="width:100%;height:100%;"></iframe>'
            href: $.webPath() + '/' + url
        });
    }
}



// 显示库存图表，隐藏销售单、采购单图片
function kclClick() {
    $.ajax({
        type: "POST",
        url: $.webPath() + "/main/getKcTbsj",
        dataType: "text",
        beforeSend: function () {
            $.messager.progress();
        },
        success: function (result) {
            var dataJson = eval("(" + result + ")");
            $.messager.progress("close");
            if (null != dataJson.listXdata && null != dataJson.listYdata) {
                $('#kc_container').highcharts({
                    chart: {
                        type: 'column',
                        marginBottom: 30
                    },
                    title: {
                        text: '公司库存量',
                        fontSize: '18px',
                        x: -20
                    },
                    xAxis: {
                        categories: dataJson.listXdata,
                        labels: {
                            rotation: -45,
                            align: 'right',
                            style: {
                                fontSize: '13px',
                                fontFamily: 'Verdana, sans-serif'
                            }
                        }
                    },
                    yAxis: {
                        min: 0,
                        title: {
                            text: '库存数量(吨)'
                        },
                        tickPixelInterval: 25
                    },
                    legend: {
                        enabled: false
                    },
                    tooltip: {
                        formatter: function () {
                            return '<b>' + this.x + '</b><br/>' +
                                '库存数量: ' + Highcharts.numberFormat(this.y, 1) +
                                ' 吨';
                        }
                    },
                    series: [
                        {
                            name: '公司库存量',
                            data: dataJson.listYdata,
                            dataLabels: {
                                enabled: true,
                                rotation: -90,
                                color: '#FFFFFF',
                                align: 'right',
                                x: 4,
                                y: 10,
                                style: {
                                    fontSize: '10px',
                                    fontFamily: 'Verdana, sans-serif'
                                }
                            }
                        }
                    ]
                });
            }

        }
    });
    document.getElementById("kc_container").style.display = "";
    document.getElementById("xc_container").style.display = "none";
    $("#kcl_id").attr("style", "float:left;height:18px;line-height:18px;padding:0 5px;background: #f45212;color: #ffffff;");
    $("#xscg_id").attr("style", "float:left;height:18px;line-height:18px;padding:0 5px;background: #737373;color: #ffffff;");
}

// 隐藏库存图表，显示销售单、采购单图片
var date = new Date();
var nowYear = date.getFullYear() + "年收入状况";
function ywsrClick() {
    // 销售单，采购单
    $.ajax({
        type: "POST",
        url: $.webPath() + "/main/getSrTbsj",
        dataType: "text",
        beforeSend: function () {
            $.messager.progress();
        },
        success: function (data) {
            var resultJson = eval("(" + data + ")");
            $.messager.progress("close");
            if (null != resultJson.listXdate && (null != resultJson.listBgywsrYdata || null != resultJson.listJyywsrYdata)) {
                $('#xc_container').highcharts({
                    credits: {
                        text: '',
                        href: '#'
                    },
                    chart: {
                        type: 'line',
                        marginRight: 80,
                        marginBottom: 30
                    },
                    title: {
                        text: nowYear,
                        x: -20 //center
                    },
                    xAxis: {
                        categories: resultJson.listXdate
                    },
                    yAxis: {
                        title: {
                            text: '收入金额(元)'
                        },
                        min: 0,
                        tickPixelInterval: 25
                    },
                    tooltip: {
                        valueSuffix: '元'
                    },
                    legend: {
                        layout: 'vertical',
                        align: 'right',
                        verticalAlign: 'top',
                        x: -10,
                        y: 100,
                        borderWidth: 0
                    },
                    series: [
                        {name: '保供业务', data: resultJson.listBgywsrYdata},
                        {name: '经营业务', data: resultJson.listJyywsrYdata}
                    ]
                });
            }
        }
    });
    document.getElementById("kc_container").style.display = "none";
    document.getElementById("xc_container").style.display = "";
    $("#kcl_id").attr("style", "float:left;height:18px;line-height:18px;padding:0 5px;background: #737373;color: #ffffff;");
    $("#xscg_id").attr("style", "float:left;height:18px;line-height:18px;padding:0 5px;background: #f45212;color: #ffffff;");
}
